<?php

class CommentController extends Controller{
	
	public function actionSubmit(){
		if(User::id()==0){
    		echo '0';
    		exit;
    	}
		$commentContent = trim($_REQUEST['content']);	
		$bookId = intval(trim($_REQUEST['bookid']));
		$commentId = CommentService::save($bookId,$commentContent);
		if($commentId > 0){
			$smarty = Yii :: app()->smarty;
			$smarty->clear_cache('book/view.tpl','book_'.$bookId);
			$smarty->clear_cache('index.tpl');
		}
		echo $commentId;	
	}
}